(require '[fx-clj.internal.util])
(fx-clj.internal.util/ns-start-loading 'fx-clj.util)

(ns ^:no-doc fx-clj.util
  (:require
    [fx-clj.impl.bootstrap]
    [fx-clj.impl.util :refer [javadoc-link]]))

;; <<----------------------
(fx-clj.internal.util/ns-libs-loaded 'fx-clj.util)
;; ---------------------->>

;; From https://gist.github.com/zilti/6286307:
(defn event-handler*
  [f]
  (reify javafx.event.EventHandler
    (handle [_ e] (f e))))

;; From https://gist.github.com/zilti/6286307:
(defmacro event-handler
  {:doc        (str "Wraps a " (javadoc-link javafx.event.EventHandler) ": (event-handler \\[e\\] (do-something))")
   :doc/format :markdown}
  [arg & body]
  `(event-handler* (fn ~arg ~@body)))

(defn callback*
  [f]
  (reify javafx.util.Callback
    (call [_ e] (f e))))

(defmacro callback
  {:doc        (str "Wraps a " (javadoc-link javafx.util.Callback) ": (callback  \\[p\\] (do-something))")
   :doc/format :markdown}
  [arg & body]
  `(callback* (fn ~arg ~@body)))

;;(defn get-scene [node] (.getScene node))

;;(defn get-root [node] (.getRoot (.getScene node)))

(defn lookup
  "Looks up a CSS selector string (or keyword) on a JavaFX Scene or Node."
  [^javafx.scene.Node scene-or-node selector]
  (.lookup scene-or-node (name selector)))

(defn cell-value-factory [v]
  (javafx.scene.control.cell.MapValueFactory. v))



(fx-clj.internal.util/ns-loaded 'fx-clj.util)